﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace ObjectPoolDemo
{
    public class Connection
    {
        public int ConnectionId { get; set; }

        public string ConnectionName { get; set; }

        public DateTime CreateTime { get; set; }

        public Connection()
        {
            // Simulate time-consuming operations
            Thread.Sleep(3000);

            CreateTime = DateTime.Now;
            ConnectionId = Counter++;
            ConnectionName = $"The No.{ConnectionId} Connection.";
        }


        public override string ToString()
        {
            return $"Hello, this is {ConnectionName} created by {CreateTime}.";
        }

        public static int Counter = 0;
    }
}
